package max.ta.stock.indicator;

import java.util.List;

import max.ta.data.entity.StockQuote;
import max.ta.data.entity.StockValueType;

public abstract class AbstractIndicator {

    public double sum(List<StockQuote> quotes, StockValueType type) {
	double sum = 0;
	for (StockQuote q : quotes) {
	    sum = sum + getValue(q, type);
	}
	return sum;
    }

    private double getValue(StockQuote q, StockValueType type) {
	switch (type) {
	    case OPEN:
		return q.getOpen();
	    case LOW:
		return q.getLow();
	    case HIGH:
		return q.getHigh();
	    case CLOSE:
		return q.getClose();
	    case VOLUME:
		return q.getVolume();
	}
	return 0;
    }
}
